package com.ldc.wandroid.adapter;

import android.widget.CheckBox;

import androidx.annotation.NonNull;
import com.ldc.common.common.CommonRecyclerView;
import com.ldc.common.common.CommonRecyclerViewHolder;
import com.ldc.common.utils.TimeUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.ldc.wandroid.R;
import com.ldc.wandroid.model.SquareArticleModel;
import org.jetbrains.annotations.NotNull;

import java.sql.Date;

public class SquareArticleAdapter extends CommonRecyclerView<SquareArticleModel> {

    public SquareArticleAdapter() {
        super(R.layout.layout_item_square_article);
    }

    @Override
    protected void convert2Data(@NonNull @NotNull CommonRecyclerViewHolder baseViewHolder, SquareArticleModel bean, int position) {
        if (null != bean) {
            baseViewHolder.setText(R.id.tv_title, String.format("%s•%s", bean.getSuperChapterName(), bean.getChapterName()));
            baseViewHolder.setText(R.id.tv_context, String.format("%s", bean.getTitle()));
            baseViewHolder.setText(R.id.tv_author, String.format("%s", bean.getShareUser()));
            baseViewHolder.setText(R.id.tv_time, String.format("%s", TimeUtils.date2String(new Date(bean.getPublishTime()), "yyyy/MM/dd")));

            ((CheckBox) baseViewHolder.findViewById(R.id.ck_collect)).setChecked(bean.isCollect());

        }
    }
}
